<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;

class Tag extends BaseModel
{
    use HasFactory;
    protected $table = "tag";
    protected $fillable = ['name', 'site_id'];
    protected $casts = [
        'created_at' => 'datetime:Y-m-d',
        'updated_at' => 'datetime:Y-m-d',
    ];

    //关联标签，标签组列表
    public function tagAndGroup(){
        return $this->belongsToMany("App\Models\TagGroup","tag_group_tag","tag_id","group_id")->withPivot("sort");
    }
}
